//
//  UserGuideViewController.m
//  GuideView
//
//  Created by lanou on 15/11/2.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "UserGuideViewController.h"
#import "PKRootLeftViewController.h"
@interface UserGuideViewController ()<UIScrollViewDelegate>
@property (nonatomic, strong) UIScrollView *myView;
@property (nonatomic, strong) UIPageControl *pageControl;
@property (nonatomic, strong) UIButton *enterBtn;
@end

@implementation UserGuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = YES;
    self.myView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    _myView.contentSize = CGSizeMake(SCREEN_WIDTH * 5, 0);
    _myView.delegate = self;
    _myView.pagingEnabled = YES;
    
    
    NSArray *array = @[@"聆听书中的声音\n感悟人生的哲学", @"畅游在音乐的海洋\n我们还会祈求什么", @"给宝宝一个难忘的童年\n就是人生的一大赢家", @"透过历史的迷雾\n找寻那曾经的真实", @"激情、爱情、友情\n影视中那自我的感动…"];
    for (int i = 0; i < 5; i ++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"guide%d.jpg", i + 1]];
        imageView.alpha = 0.8;
        UILabel *descLabel= [[UILabel alloc] initWithFrame:CGRectMake(40 + i * SCREEN_WIDTH, 100, SCREEN_WIDTH - 80, 60)];
        descLabel.font = [UIFont systemFontOfSize:24];
        descLabel.textAlignment = NSTextAlignmentCenter;
        descLabel.text = array[i];
        descLabel.numberOfLines = 0;
        [_myView addSubview:imageView];
        [_myView addSubview:descLabel];
    }
    [self.view addSubview:_myView];
//    [self.view addSubview:_descLabel];
    
    
    self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 - 50, SCREEN_HEIGHT - 100, 100, 30)];
    _pageControl.numberOfPages = 5;
    _pageControl.currentPageIndicatorTintColor = [UIColor greenColor];
    _pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
    [self.view addSubview:_pageControl];
    
    self.enterBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _enterBtn.frame = CGRectMake(SCREEN_WIDTH / 2 - 50, SCREEN_HEIGHT - 70, 100, 30);
    [_enterBtn setTitle:@"立即进入" forState:(UIControlStateNormal)];
//    [_enterBtn setTitleColor:[UIColor blueColor] forState:(UIControlStateNormal)];
    [_enterBtn addTarget:self action:@selector(enterRootView) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:_enterBtn];
    // Do any additional setup after loading the view from its nib.
}
- (void)enterRootView{
    PKRootLeftViewController *leftView = self.rootLeftVC;
    
    [UIView animateWithDuration:2.0 animations:^{

        [self.navigationController pushViewController:leftView animated:YES];
    }];
   
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
   _pageControl.currentPage = scrollView.contentOffset.x / SCREEN_WIDTH;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
